#pragma once

#include "../shared/shared_types.h"
#include "GameObject.h"
#include <string>

namespace Putin{

class Player;
struct DynamicObjectConstants;

/*!
 * \brief
 * A general game unit representation- 
 * 
 * Intended to be derived to fit particular needs
 * for a game state unit object. 
 * 
 * \remarks
 * Only general case data here that might be needed 
 * for intersystem comm. or network comm. .
 * 
 */
class Unit : public GameObject
{
public:
	Unit(void);
	virtual ~Unit(void);

	enum State // hex format. So that 
	{
		IDLE		= 0x1,
		ATTACKING	= 0x2,
		MOVING		= 0x4
	};

	// -- TODO: ADD Game specific things here

	/*!
	 * \brief Get the player 
	 * \returns The player responsible for this unit
	 */
	Player* getPlayer(){return mPlayer;}

	virtual Vec3f& getNextWaypoint(){ return mNextWP;}
	virtual void setNextWaypoint(Vec3f& wp){mNextWP = wp;}
	virtual Vec3f& getMoveTarget(){ return mMoveTarget;}

	virtual Vec3f& getShootingTarget(){ return mShootingTarget;}
	virtual void setShootingTarget(Vec3f& wp){mShootingTarget = wp;}

	virtual double getLastShot(){ return mLastShot;}
	virtual void setLastShot(double t){mLastShot = t;}

	virtual float getShootingCooldown(){ return mShootingCooldown;}

	virtual bool getIsShooting(){ return mIsShooting;}
	virtual void setIsShooting(bool s){mIsShooting = s;}

	virtual float getShootingRange(){ return mShootingRange;}

	virtual void shootAt(Vec3f& p) {
		mShootingTarget = p;
		mIsShooting = true;
	}

	virtual void stopShooting() {
		mShootingTarget = Vec3f();
		mIsShooting = false;
	}

	virtual void moveTo(Vec3f& p)
	{
		mMoveTarget = p; 
		setState(MOVING);
	}
	virtual std::pair<Vec3f,Vec3f> getAABB();
	virtual State getState(){return mState;}
	virtual void setState(State s){mState = s;}

public:
	DynamicObjectConstants* mConstants;
	float mMaxSpeed;

protected:

	State	mState;
	Player* mPlayer;
	Vec3f mNextWP;
	Vec3f mMoveTarget;


	bool mIsShooting;
	Vec3f mShootingTarget;
	float mShootingRange;
	double mLastShot;
	float mShootingCooldown;
	
};

}